import React from 'react'

export default () =>
{
    //创建表单
    const [form] = React.UI.Form.useForm()

    const AddGuestFinish = async (values: any) =>
    {
        values.busid = React.business.id

        let result = await React.request.post('/guest/GuestAdd', values)

        if(result.code == 0)
        {
            React.toast(result.msg)
            return false
        }

        React.toast(result.msg, 'back')
    }




    return (
        <>
            <React.UI.Form
                form={form}
                layout="horizontal"
                initialValues={{mobile: '13512645456', nickname: '张三'}}
                onFinish={AddGuestFinish}
                footer={
                    <React.UI.Button block type="submit" color="primary" size="large">
                        提交
                    </React.UI.Button>
                }
            >
                {/* 昵称 */}
                <React.UI.Form.Item name="nickname" label="昵称" rules={[{required: true}]}>
                    <React.UI.Input placeholder="请输入昵称" />
                </React.UI.Form.Item>

                {/* 手机号码 */}
                <React.UI.Form.Item name="mobile" label="手机号码" rules={[{ required: true }, { pattern: /^1[3456789]\d{9}$/, message: '手机号格式不对' }]}>
                    <React.UI.Input placeholder='请输入手机号' />
                </React.UI.Form.Item>

                {/* 性别 */}
                <React.UI.Form.Item name="gender" label="性别" rules={[{required: true}]}>
                    <React.UI.Radio.Group>
                        <React.UI.Space direction="horizontal">
                            <React.UI.Radio value='0'>女</React.UI.Radio>
                            <React.UI.Radio value='1'>男</React.UI.Radio>
                        </React.UI.Space>
                    </React.UI.Radio.Group>
                </React.UI.Form.Item>
            </React.UI.Form>
        </>
    )
}